using System;

namespace Dorm.QueryObject
{
    public class Parameter
    {
        public string PropertyName { get; set; }
        private object _propertyValue;
        public object PropertyValue
        {
            get { return GetDbValue(_propertyValue); }
            set { _propertyValue = value; }
        }

        public static string GetDbValue(object value)
        {
            if (value == null)
                return "NULL";

            if (value.ToString().StartsWith("SELECT"))
                return value.ToString();

            switch (value.GetType().Name)
            {
                case "DateTime":
                case "Int16":
                case "Int32":
                case "Int64":
                case "Decimal":
                case "Double":
                    return value.ToString();
                default:
                    return "'" + value + "'";
                    
            }
        }
    }
}
